package com.goldenKey.admin.controller;

import com.goldenKey.common.pojo.result.R;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.goldenKey.common.pojo.po.Notification;
import com.goldenKey.admin.service.INotificationService;

/**
 * @Author: 吃我一钊
 * @Description: 控制层
 * @Date: 2025/02/02
 */
@RestController
@RequestMapping("/notification")
public class NotificationController {

	@Autowired
	private INotificationService notificationService;

	/**
	 * 新增数据
	 * @param notification
	 * @return
	 */
	@PostMapping("/save")
	public R<Void> save(@RequestBody Notification notification) {
		notificationService.save(notification);
		return R.ok();
	}

	/**
	 * 根据id删除
	 * @param notificationId
	 * @return
	 */
	@DeleteMapping("/deleteById/{notificationId}")
	public R<Void> deleteById(@PathVariable("notificationId") Integer notificationId) {
		notificationService.removeById(notificationId);
		return R.ok();
	}

	/**
	 * 根据id修改数据
	 * @param notification
	 * @return
	 */
	@PutMapping("/updateById")
	public R<Void> updateById(@RequestBody Notification notification) {
		notificationService.updateById(notification);
		return R.ok();
	}

	/**
	 * 根据id查询数据
	 * @param notificationId
	 * @return
	 */
	@GetMapping("/getById/{notificationId}")
	public R<Notification> getById(@PathVariable("notificationId") Integer notificationId) {
		Notification notification = notificationService.getById(notificationId);
		return R.ok(notification);
	}
	/**
	 * 查询所有数据
	 * @return
	 */
	@GetMapping("/list")
	public R<List<Notification>> list() {
		List<Notification> notificationList = notificationService.list();
		return R.ok(notificationList);
	}

}